#include "iap/include/iap_file.h"

IapFile::IapFile() : __file()
{
    // PASS
}


void IapFile::SetFile(const QString &path)
{
    __file.setFileName(path);
}

QString IapFile::GetFilename()
{
    QStringList pathlist = __file.fileName().split(u'/', Qt::SkipEmptyParts);
    QString qname = pathlist.last();
    return qname;
}

bool IapFile::Open()
{
    if (__file.isOpen()) {
        __file.close();
    }
    return __file.open(QIODeviceBase::ReadWrite, QFileDevice::ReadOther);
}

void IapFile::Close()
{
    __file.close();
}

qint64 IapFile::Size()
{
    return __file.size();
}

qint64 IapFile::Read(char * buf, qint64 len)
{
    return __file.read(buf, len);
}

qint64 IapFile::Write(const QByteArray &data)
{
    return __file.write(data);
}

void IapFile::FromBegin()
{
    __file.seek(0);
}

